package com.dongan.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dongan.mapper.ModuleDetailsMapper;
import com.dongan.pojo.Codes;
import com.dongan.mapper.CodesMapper;
import com.dongan.pojo.File;
import com.dongan.pojo.ModuleDetails;
import com.dongan.service.CodesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dongan.service.FileService;
import com.dongan.service.ModuleDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 模块详细信息 服务实现类
 * </p>
 *
 * @author longTao
 * @since 2021-06-15
 */
@Service
public class ModuleDetailsServiceImpl extends ServiceImpl<ModuleDetailsMapper, ModuleDetails> implements ModuleDetailsService {
    @Autowired
    private ModuleDetailsMapper mapper;
    @Autowired
    private FileService fileService;
    /**
     * 根据产品编号获取物料明细
     *
     * @param productId
     * @return
     */
    @Override
    public List<ModuleDetails> queryModuleDetailByProductId(String productId) {
        QueryWrapper<File> queryWrapper=new QueryWrapper<File>();
        queryWrapper.eq("PRODUCT_ID",productId);
        File file=fileService.getOne(queryWrapper);
        if("W001-1".equals(file.getDesignModuleTag())){
            return mapper.queryModuleDetailByProductId(productId);
        }
        return null;
    }
}
